import { h } from 'vue';
import { NTag } from 'naive-ui';
import { BasicColumn } from '@/components/Table';

export const columns: BasicColumn[] = [
  {
    type: 'selection',
  },
  {
    title: '账号',
    key: 'username',
  },
  {
    title: '用户名',
    key: 'nickname',
  },
  {
    title: '手机',
    key: 'mobile',
  },
  {
    title: '邮箱',
    key: 'email',
  },
  {
    title: '性别',
    key: 'sex',
    render(row) {
      return h(
        NTag,
        {
          type: 'info',
        },
        {
          default: () => (row.sex === 0 ? '男' : row.sex === 1 ? '女' : '未知'),
        },
      );
    },
  },
  {
    title: '角色',
    key: 'roleNames',
    render(row) {
      const tags = row.roleNames.map((name) => {
        return h(
          NTag,
          {
            style: {
              marginRight: '6px',
            },
            type: 'info',
            bordered: false,
          },
          {
            default: () => name,
          },
        );
      });
      return tags;
    },
  },
  {
    title: '个人介绍',
    key: 'remark',
  },
  {
    title: '创建时间',
    key: 'created_at',
  },
];
